package com.zzsy.carosshopprojects.activitys.home.mainpage.orderamount;

import android.content.Context;

import com.king.base.util.ToastUtils;
import com.zzsy.carosshopprojects.base.BaseViewMode;
import com.zzsy.carosshopprojects.bean.OrderZongBean;
import com.zzsy.carosshopprojects.bean.ReghterOrderBean;
import com.zzsy.carosshopprojects.network.RequestUtils;
import com.zzsy.carosshopprojects.network.Utils.MyObserver;
import com.zzsy.carosshopprojects.util.DataUtil;

import androidx.lifecycle.MutableLiveData;

public class OrderReghterAmountMode extends BaseViewMode {
    private MutableLiveData<ReghterOrderBean> liveData;
    private MutableLiveData<OrderZongBean> liveDataOz;

    public MutableLiveData<ReghterOrderBean> getLiveData() {
        if (liveData == null)
            liveData = new MutableLiveData<>();
        return liveData;
    }

    public MutableLiveData<OrderZongBean> getLiveDataOz() {
        if (liveDataOz == null)
            liveDataOz = new MutableLiveData<>();
        return liveDataOz;
    }

    /**
     * 获取订单列表数据
     *
     * @param context
     * @param page
     */
    public void getOrdersByTerminalId(Context context, String page, boolean isShowDialog) {
        RequestUtils.GetOrdersByTerminalId(context,DataUtil.getInstance().getTerminalId(), page, new MyObserver<ReghterOrderBean>(context,isShowDialog) {
            @Override
            public void onSuccess(ReghterOrderBean result) {
                liveData.postValue(result);
            }

            @Override
            public void onFailure(Throwable e, String errorMsg, int code) {
                ToastUtils.showToast(context.getApplicationContext(), errorMsg);
                liveData.postValue(null);
            }
        });
    }


}
